#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=4e5+5;
int n;
ll pre[N],suf[N];
signed main()
{
	freopen("kte.in","r",stdin);
	freopen("kte.out","w",stdout);
	ios::sync_with_stdio(0),cin.tie(0);
	cin>>n; set<ll>s;
	while(n--)
	{
		ll x; cin>>x;
		if(s.find(x)!=s.end()) s.erase(x);
		else s.insert(x);
		vector<ll>a(1,0);
		for(auto it:s) a.push_back(it);
		int sz=(int)a.size()-1;
		for(int i=1;i<=sz;i++) pre[i]=pre[i-1]+a[i];
		suf[sz+1]=0;
		for(int i=sz;i>=1;i--) suf[i]=suf[i+1]+a[i];
		ll ans=0;
		for(int i=0;i<sz;i++)
			if(pre[i+1]>suf[sz-i+1]) ans+=pre[i+1]-suf[sz-i+1];
		cout<<pre[sz]-ans<<"\n";
	}
	return 0;
}
/*
2 4
*/
